# -*- coding:utf-8 -*-

import os


def main():
    filepath = os.path.join(r'D:\Program Files (x86)\sscom',
                            '0fDC.DAT')
    f = open(filepath, 'rb')
    content = f.read()
    f.close()
    x1, y1, x2, y2 = 0x00, 0x00, 0x0f, 0x0f
    start = 0xA9f7 - 0x9000
    high = abs(y2-y1)+1
    width = abs(x2-x1)+1
    length = (width+7)//8*high
    print('width:', width, ', high:', high)
    print('data length: 0x{:04X}'.format(length))
    # print(content[start:start+length])
    buff = ''
    for i in range(length):
        buff += '{:08b}'.format(content[start+i])
    for y in range(high):
        for x in range(width):
            print(buff[(width+7)//8*8*y+x].replace('0', '  ').replace('1', '██'), end='')
        print('')
    print('-'*100)
    for y in range(high):
        for x in range(width):
            print(buff[(width+7)//8*8*y+x].replace('0', '  ').replace('1', '█'), end='')
        print('')
    print('-'*100)
    print(','.join(['0x{:02X}'.format(content[start+i]) for i in range(length)]))


if __name__ == '__main__':
    main()